package xml.manager;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;

import xml.laberinto.XmlLaberinto;

import dominio.Laberinto;

public class PersistenciaLaberinto extends PersistenciaGenerico<XmlLaberinto> {
	
	private static PersistenciaLaberinto instance;
	
	private PersistenciaLaberinto() {
		super(XmlLaberinto.class);
	}
	
	
	public static PersistenciaLaberinto getInstance() {
		if (instance == null) {
			instance = new PersistenciaLaberinto();
		}
		return instance;
	}


	public Laberinto cargarLaberinto(String path) throws FileNotFoundException {
        return super.cargar(path).getLaberinto();
	}
	
	public Laberinto cargarLaberinto(Reader inputStream) {		
		return super.cargar(inputStream).getLaberinto();
	}
	
	public void guardarLaberinto(Laberinto laberinto, String path) throws IOException {
		XmlLaberinto xmlLaberinto = new XmlLaberinto(laberinto);
		super.guardar(xmlLaberinto, path);
	}
	
	public void guardarLaberinto(Laberinto laberinto, Writer outputStream) {
		XmlLaberinto xmlLaberinto = new XmlLaberinto(laberinto);
		super.guardar(xmlLaberinto, outputStream);
	}
}
